package com.qfedu.springboot1.service.impl;

import cn.hutool.http.HttpUtil;
import com.qfedu.springboot1.service.WeatherService;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 千锋Java,为你而生！
 *
 * @Author: Feri
 * @Date:2024/10/31 14:52
 * @Modified:
 */
@Service //IOC 创建对象
public class WeatherServiceImpl implements WeatherService {
    @Override
    public String queryByCity(String city) {
        //1.准备接口请求参数
        Map<String,Object> param=new HashMap<>();
        //在个人中心->我的数据,接口名称上方查看
        param.put("key","231c3bef279cb8c55c624008d2e7dd14");
        param.put("city",city);

        //2.请求对应的天气接口 获取对应的天气信息
        return HttpUtil.get("http://apis.juhe.cn/simpleWeather/query",param);
    }
}
